package com.candy.control;

import com.candy.pojo.UserBean;
import com.candy.service.LoginService;
import com.candy.service.UserInfoService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/getUserInfoservlet")
public class UserInfoQueryServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("访问后台成功............");
//        设置字符集，处理中文乱码问题
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
//调用业务逻辑处理层进行业务处理
        UserInfoService userInfoService=new UserInfoService();
       List<UserBean> luser= userInfoService.getUserInfo();

           req.getSession().setAttribute("userinfoes",luser);
//           若用户名密码正确，则跳转到登录成功页面
           req.getRequestDispatcher("WEB-INF/userManger/userInfoQuery.jsp").forward(req,resp);





    }
}
